#include "formtkaoqin.h"
#include "ui_formtkaoqin.h"
#include<QMessageBox>
#include<QSqlDatabase>
#include<QSqlQueryModel>
#include"teacher.h"
#include"execsql.h"
#include<QDebug>

FormTkaoqin::FormTkaoqin(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormTkaoqin)
{
    ui->setupUi(this);
}

FormTkaoqin::~FormTkaoqin()
{
    delete ui;
}

void FormTkaoqin::showFormTkaoqin()
{
    emit signalformtkaoqin();
    this->show();
}

void FormTkaoqin::on_pb_checkin_ok_clicked()
{
    ExecSQL sql;
    m_str =sql.selectTeacherInfo(str).getteacherID();
    QSqlQueryModel *model1 = new QSqlQueryModel(ui->tableView_checkin);
        if(ui->lineEdit_checkin_classid->text() == "all")
        {
             model1->setQuery(QString("select * from CheckinInfoTable where teacherId = '%1';").arg(m_str));
         }else{
            model1->setQuery(QString("select * from CheckinInfoTable where Classid = '%1' and teacherId = '%2' ;").arg(ui->lineEdit_checkin_classid->text()).arg(m_str));
        }
    //列名
    model1->setHeaderData(0, Qt::Horizontal, tr("XID"));
    model1->setHeaderData(1, Qt::Horizontal, tr("ScienceID"));
    model1->setHeaderData(2, Qt::Horizontal, tr("teacherId"));
    model1->setHeaderData(3, Qt::Horizontal, tr("Classid"));
    model1->setHeaderData(4, Qt::Horizontal, tr("RoomID"));
    model1->setHeaderData(6, Qt::Horizontal, tr("xuehao"));
    model1->setHeaderData(5, Qt::Horizontal, tr("CheckinTime"));

    ui->tableView_checkin->setModel(model1);//数据放置进去
    ui->tableView_checkin->verticalHeader()->hide();//不显示序号
}

void FormTkaoqin::showtw()
{
    Teacher *tw = new Teacher;
    tw->show();
    tw->selectBoxSlot(str);
}
void FormTkaoqin::on_pushButton_cancle_clicked()
{
    this->close();
    this->showtw();

}
